package io.renren.modules.pay_spend.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.CommonUtils;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.pay_spend.dao.V9PaySpendDao;
import io.renren.modules.pay_spend.entity.V9PaySpendEntity;
import io.renren.modules.pay_spend.service.V9PaySpendService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("v9PaySpendService")
public class V9PaySpendServiceImpl extends ServiceImpl<V9PaySpendDao, V9PaySpendEntity> implements V9PaySpendService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String username = (String)params.get("username");
        String op_username = (String)params.get("op_username");
        String start = (String)params.get("start");
        String end = (String)params.get("end");
        Integer sInteger=0,eInteger=0;
        if (StringUtils.isNotBlank(start)) {
            sInteger= CommonUtils.timeStrToTimeStamp3(start);
            eInteger=CommonUtils.timeStrToTimeStamp3(end);
        }

        IPage<V9PaySpendEntity> page = this.page(
                new Query<V9PaySpendEntity>().getPage(params,"id",false),
                new QueryWrapper<V9PaySpendEntity>()
                        .like(StringUtils.isNotBlank(username), "username", "%"+username+"%")
                        .like(StringUtils.isNotBlank(op_username), "op_username", "%"+op_username+"%")
                        .between(StringUtils.isNotBlank(start), "creat_at", sInteger, eInteger));
        return new PageUtils(page);
    }
}
